package cz.semjobKB.virtuoso.service.api;

import cz.semjobKB.knowledge.api.IExtractedKnowledge;
import cz.semjobKB.virtuoso.document.api.IDocumentDetail;
import cz.semjobKB.virtuoso.document.api.IResourceDetail;
import cz.semjobKB.virtuoso.document.api.ITerminologyDetail;
import cz.semjobKB.virtuoso.document.api.ITripleDbItem;
import cz.semjobKB.virtuoso.utils.ELanguage;

import java.io.File;
import java.util.List;

/**
 *
 */
public interface IDatabaseService {
	
	/**
	 * Stores extracted knowledge into the database
	 * 
	 * @param extractedKnowledge extracted knowledge
	 * @param document document file
	 * @param language language of the document
	 * @return document detail or null
	 */
	public IDocumentDetail storeDocument(IExtractedKnowledge extractedKnowledge, File document, ELanguage language);
	
	/**
	 * Gets document knowledge based on document name
	 * @param documentName document name to find
	 * @return document detail or null
	 */
	public IDocumentDetail getDocumentDetails(String documentName);
	
	/**
	 * Gets resource details for subject, predicate object from the database
	 * @param resourceName resource name
	 * @return resource detail or null
	 */
	public List<IResourceDetail> getResourceDetail(String resourceName);
	
	/**
	 * Gets terminology detail from the database
	 * @param terminologyName text or lemma of a terminology
	 * @return terminology detail or null
	 */
	public List<ITerminologyDetail> getTerminologyDetail(String terminologyName);
	
	/**
	 * Searches for triples based on not fully triple specified
	 * @param subject   Subject text or lemma
	 * @param predicate Predicate text or lemma
	 * @param object    Object text or lemma
	 * @return          List of found triples
	 */
	public List<ITripleDbItem> searchTriples(String subject, String predicate, String object);
	
	/**
	 *  Searches for document based on triple parts
	 * @param subject   Subject text or lemma
	 * @param predicate Predicate text or lemma
	 * @param object    Object text or lemma
	 * @return          List of matching documents
	 */
	List<IDocumentDetail> searchDocument(String subject, String predicate,
			String object);
	
	/**
	 * Searches for document based on a terminology
	 * @param queryTerminology  Terminology text or lemma
     * @param frequencyLimit    Limit for TF_IDF value
	 * @return                  List of matching documents
	 */
	public List<IDocumentDetail> searchDocument(String queryTerminology, double frequencyLimit);
	
}
